<template>
  <div class="homeNewSongContainer">
    <div class="songLeftCover">
      <img :src="song.picUrl" :alt="song.name" />
      <div class="innerIcon">
        <SvgIcon icon-name="iconbofang" color="#d989b1" :size="14" />
      </div>
    </div>
    <div class="songRightInfo">
      <div class="songRightInfoRow">
        <span class="songName">
          {{ song.name }}
        </span>
        <span
          class="songAlias"
          v-if="
            song.song?.alias instanceof Array && song.song?.alias?.length > 0
          "
        >
          {{ `(${song.song.alias.join("/")})` }}
        </span>
      </div>
      <div class="songRightInfoRow">
        <span class="songQuality borderLabel" v-if="quality !== ''">
          {{ quality }}</span
        >
        <span class="MVbtn borderLabel" v-if="song.song.mvid !== 0">MV</span>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { computed } from "vue";
import { HomeNewSong } from "@/types/index";
import SvgIcon from "./SvgIcon.vue";

const props = defineProps<{
  song: HomeNewSong;
}>();

const quality = computed(() => {
  let result = "";
  let trueSong = props.song.song;
  if (trueSong.sqMusic) {
    result = "SQ";
  }
  if (trueSong.hrMusic) {
    result = "Hi-Res";
  }
  return result;
});
</script>

<style scoped lang="less">
.homeNewSongContainer {
  display: flex;
  height: 50px;
  border-radius: 4px;
  overflow: hidden;
  background-color: #fff;
  &:hover {
    background-color: rgb(235, 235, 235);
  }
  .songLeftCover {
    width: 50px;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    img {
      width: 100%;
      height: 100%;
    }
    .innerIcon {
      cursor: pointer;
      width: 26px;
      height: 26px;
      border-radius: 50%;
      background-color: rgba(255, 255, 255, 0.9);
      display: flex;
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-13px, -13px);
      justify-content: center;
      align-items: center;
    }
  }
  .songRightInfo {
    padding-left: 10px;
    width: calc(100% - 50px);
    .MVbtn {
      cursor: pointer;
      margin-left: 6px;
      &:hover {
        color: var(--primary-highlight);
        border-color: var(--primary-highlight);
      }
    }
    .borderLabel {
      height: 12px;
      padding: 0px 1px;
      font-size: 10px;
      color: var(--primary-color);
      border: 1px solid var(--primary-color);
      border-radius: 2px;
    }

    .songRightInfoRow {
      height: 50%;
      overflow: hidden;

      white-space: nowrap;
      .songName {
        font-size: 14px;
        color: #555;
        margin-right: 5px;
      }
      .songAlias {
        font-size: 14px;
        color: #aaa;
      }
    }
  }
}
</style>
